package com.szq.lottery.domain.award.service.goods.impl;

import com.szq.lottery.common.Constants;
import com.szq.lottery.domain.award.model.req.GoodsReq;
import com.szq.lottery.domain.award.model.res.DistributionRes;
import com.szq.lottery.domain.award.service.goods.DistributionBase;
import com.szq.lottery.domain.award.service.goods.IDistributionGoods;
import org.springframework.stereotype.Component;

/**
 * @author 吾空白
 * @description: 优惠券商品
 */
@Component
public class CouponCoods extends DistributionBase implements IDistributionGoods {
    @Override
    public DistributionRes doDistribution(GoodsReq req) {
        //模拟调用优惠劵发放接口
        logger.info("模拟调用优惠卷发放接口 uId:{} awardContent:{}",req.getuId(),req.getAwardContent());
        //更新用户领奖结果
        super.updateUserAwardState(req.getuId(), req.getOrderId(), req.getAwardId(), Constants.GrantState.COMPLETE.getCode());

        return new DistributionRes(req.getuId(),Constants.AwardState.SUCCESS.getCode(),Constants.AwardState.SUCCESS.getInfo());
    }

    @Override
    public Integer getDistributionGoodsName() {
        return Constants.AwardType.CouponGoods.getCode();
    }
}
